<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="https://www.hualigs.cn/image/6015799666530.jpg">
  <link rel="icon" type="image/png" sizes="32x32" href="https://www.hualigs.cn/image/6015799666530.jpg">
  <link rel="icon" type="image/png" sizes="16x16" href="https://www.hualigs.cn/image/6015799666530.jpg">
  <link rel="mask-icon" href="https://www.hualigs.cn/image/6015799666530.jpg" color="#222">
  <link rel="manifest" href="https://www.hualigs.cn/image/6015799666530.jpg">
  <meta name="msapplication-config" content="https://www.hualigs.cn/image/6015799666530.jpg">

<link rel="stylesheet" href="/diazang/css/main.css">


<link rel="stylesheet" href="/diazang/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"jue-xian.gitee.io","root":"/diazang/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":true,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="&#x3D;-&#x3D;本来想好好打pwn结果做了签到题我就不行了 pie保护泄露我感觉没问题啊就是打不通绝了我这个憨批">
<meta property="og:type" content="article">
<meta property="og:title" content="第四届海啸杯wp">
<meta property="og:url" content="https://jue-xian.gitee.io/diazang/2021/04/05/%E7%AC%AC%E5%9B%9B%E5%B1%8A%E6%B5%B7%E5%95%B8%E6%9D%AFwp/index.html">
<meta property="og:site_name" content="RUBIA">
<meta property="og:description" content="&#x3D;-&#x3D;本来想好好打pwn结果做了签到题我就不行了 pie保护泄露我感觉没问题啊就是打不通绝了我这个憨批">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.loli.net/2021/04/05/XRgzZ8A5WVNTDsK.png">
<meta property="og:image" content="https://i.loli.net/2021/04/05/XRgzZ8A5WVNTDsK.png">
<meta property="og:image" content="https://i.loli.net/2021/04/03/I5dRoEVrtw7aXfp.png">
<meta property="og:image" content="https://i.loli.net/2021/04/05/O6zXkvroLCRyJVW.png">
<meta property="og:image" content="https://i.loli.net/2021/03/31/vU5KJhBwbFxj6Ws.png">
<meta property="og:image" content="https://i.loli.net/2021/04/05/sjIbldhcf8argPF.jpg">
<meta property="article:published_time" content="2021-04-04T20:00:07.000Z">
<meta property="article:modified_time" content="2021-04-08T12:31:53.113Z">
<meta property="article:author" content="H.R.P">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.loli.net/2021/04/05/XRgzZ8A5WVNTDsK.png">

<link rel="canonical" href="https://jue-xian.gitee.io/diazang/2021/04/05/%E7%AC%AC%E5%9B%9B%E5%B1%8A%E6%B5%B7%E5%95%B8%E6%9D%AFwp/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>第四届海啸杯wp | RUBIA</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/diazang/atom.xml" title="RUBIA" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/diazang/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">RUBIA</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/diazang/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/diazang/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/diazang/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/diazang/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/diazang/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-schedule">

    <a href="/diazang/schedule/" rel="section"><i class="fa fa-calendar fa-fw"></i>日程表</a>

  </li>
        <li class="menu-item menu-item-sitemap">

    <a href="/diazang/sitemap.xml" rel="section"><i class="fa fa-sitemap fa-fw"></i>站点地图</a>

  </li>
        <li class="menu-item menu-item-commonweal">

    <a href="/diazang/404/" rel="section"><i class="fa fa-heartbeat fa-fw"></i>公益 404</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://jue-xian.gitee.io/diazang/2021/04/05/%E7%AC%AC%E5%9B%9B%E5%B1%8A%E6%B5%B7%E5%95%B8%E6%9D%AFwp/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="https://www.hualigs.cn/image/6015786be4309.jpg">
      <meta itemprop="name" content="H.R.P">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="RUBIA">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          第四届海啸杯wp
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-04-05 04:00:07" itemprop="dateCreated datePublished" datetime="2021-04-05T04:00:07+08:00">2021-04-05</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-04-08 20:31:53" itemprop="dateModified" datetime="2021-04-08T20:31:53+08:00">2021-04-08</time>
              </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/diazang/2021/04/05/%E7%AC%AC%E5%9B%9B%E5%B1%8A%E6%B5%B7%E5%95%B8%E6%9D%AFwp/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/diazang/2021/04/05/%E7%AC%AC%E5%9B%9B%E5%B1%8A%E6%B5%B7%E5%95%B8%E6%9D%AFwp/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>=-=本来想好好打pwn结果做了签到题我就不行了</p>
<p>pie保护泄露我感觉没问题啊就是打不通绝了我这个憨批</p>
<a id="more"></a>

<h1 id="第四届海啸杯wp"><a href="#第四届海啸杯wp" class="headerlink" title="第四届海啸杯wp"></a>第四届海啸杯wp</h1><h2 id="pwn-guess"><a href="#pwn-guess" class="headerlink" title="pwn-guess"></a><strong>pwn-guess</strong></h2><p>上图关键函数</p>
<p>如图所示只检查了上溢出，但是对于数组下标为负数的下溢出没有进行检测</p>
<p><img src="https://i.loli.net/2021/04/05/XRgzZ8A5WVNTDsK.png" alt="mmexport1617566608443.png"></p>
<p>我们可以去康康数组的bss段<br>很好，num和chance，round临近</p>
<p>依据题意，我们需要答对十次，也就是让num[any]==1</p>
<p>那我们先输八次，chance因为是–chance就会变成1</p>
<p>chance不会因为答对而改变（答对了加一，重新执行guess又-1不变）</p>
<p>我们可以寻到num距离chance的距离</p>
<p>我们可以从bss段判断nums首地址和chances首地址差距十进制28</p>
<p>看见伪指令dd，可以判断为int，一个数据占位4个字</p>
<p>28/4=7，同理，rounds为8 so我们输入-7就是chances</p>
<p>-8就是round</p>
<p><img src="https://i.loli.net/2021/04/05/XRgzZ8A5WVNTDsK.png" alt="mmexport1617566608443.png"></p>
<p>实验图</p>
<p><img src="https://i.loli.net/2021/04/03/I5dRoEVrtw7aXfp.png" alt="mmexport1617459927418.png"></p>
<p>结果图</p>
<p><img src="https://i.loli.net/2021/04/05/O6zXkvroLCRyJVW.png" alt="mmexport1617568895184.png"></p>
<h2 id="misc"><a href="#misc" class="headerlink" title="misc"></a>misc</h2><h3 id="隐藏的书"><a href="#隐藏的书" class="headerlink" title="隐藏的书"></a>隐藏的书</h3><p>第一题字符隐写</p>
<!--more-->

<p>阅读所提供的文献，</p>
<p><strong>3.1 隐写信息的编码 编码算法首先应获取秘密信息每一位的 ASCII 码，之后把 ASCII 码转换为十六进制 数，最后用 Unicode 编码字符表示从 ASCII 码转换过来的十六进制数。考虑的中文 ASCII 编码的特殊性，中文一个字符占两个字节，则我们将每个字节分别转为对应 的 ASCII 码，即一个英文字符用两个不可见字符表示，而一个中文字符用四个不可 见字符表示。</strong></p>
<p>我们可以知道用101编辑器打开的那些字符就是Unicode表示的hex数，按照提示两两拼凑</p>
<p>对照16进制的ASCII表拼凑得出<strong>flag{8f807f74-9088-11eb-b255-00163e0620b4}</strong></p>
<p>ps:101中对应的00直接忽略，文献中的信息提取比较重要</p>
<p><img src="https://i.loli.net/2021/03/31/vU5KJhBwbFxj6Ws.png" alt="mmexport1617204194349.png"></p>
<p>use time:10minutes(这压缩包有毒害我换了好多软件才打开=-=)</p>
<h3 id="你能看到图片里的flag吗"><a href="#你能看到图片里的flag吗" class="headerlink" title="你能看到图片里的flag吗?"></a>你能看到图片里的flag吗?</h3><p>本来要用社会主义核心价值观密码解密==</p>
<p>但是我用画图3D打开后调个色调然后掏出手机拍照</p>
<p>非常的清晰</p>
<p>示例图</p>
<p><img src="https://i.loli.net/2021/04/05/sjIbldhcf8argPF.jpg" alt="IMG_20210404_185525.jpg"></p>
<p>拼凑完得到flag</p>
<p>flag{Th1s_1s_4_h1dden_F14g}</p>
<h3 id="神秘铃声"><a href="#神秘铃声" class="headerlink" title="神秘铃声"></a>神秘铃声</h3><p>一道非常皮的题目，第一次做杂项直接去csdn逛街</p>
<p>搜索ctf 音频</p>
<p>基本确定这题的工具有au是最长见的。。。可是我下的有问题用不了</p>
<p>还有就是DTMF类型的，我就找了解密器解出来如图</p>
<p>=-=一窜神秘东西，还是就是misc经常套娃，平时也做了点逆向</p>
<p>我就习惯性的用txt打开发现最后有一窜base64编码</p>
<p>就拿去网上转码，看见flag.txt还有文件头pk</p>
<p>想复制直接转为压缩包，结果里面有写空格之类的打不开，</p>
<p>就去csdn，看雪，博客园到处找</p>
<p>最后在csdn搜索到了这个脚本</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> base64</span><br><span class="line">code=<span class="string">&quot;&quot;</span></span><br><span class="line">r=base64.b64decode(code)</span><br><span class="line">test_file=<span class="built_in">open</span>(<span class="string">&quot;test.rar&quot;</span>,<span class="string">&quot;wb&quot;</span>)</span><br><span class="line">test_file.write(r)</span><br><span class="line">test_file.close()</span><br></pre></td></tr></table></figure>
<p>直接转为rar 好耶</p>
<p>打开发现要密码，刚才音频里面给出来的应该是</p>
<p>=-=可是我吐了呀怎么输入都不对</p>
<p>还是去csdn逛街慢慢看 找到一个比赛题提到了键盘密码</p>
<p>前面的DC9A16B不符合，后面的79176172如果两两组合的话</p>
<p>第一个范围1-9 第二数范围1-4 不符合</p>
<p>我打开了自己手机的拨号器</p>
<p>看见7第一个对应P *也对应P</p>
<p>9第一个对应#</p>
<p>其他的没有符号</p>
<p>我就想着要么 #* 要么*#去插入密码里面</p>
<p>可能还要分开</p>
<p>于是我就试了 #*DC9A16B </p>
<p>D#*C9A16B结果就很骚就在这里试出来了</p>
<p>Detect DTMF Tones：<a target="_blank" rel="noopener" href="http://dialabc.com/sound/detect/index.htm">http://dialabc.com/sound/detect/index.htm</a></p>
<p>这个网站可以直接解码DTMF</p>
<p>打开flag里面一看=-=</p>
<p>以前用pygame做过飞机大战 看见这些我想起来了坐标</p>
<p>在博客园最后找到了脚本</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> Image</span><br><span class="line"></span><br><span class="line">flag_image = Image.new(<span class="string">&#x27;RGB&#x27;</span>,(<span class="number">300</span>,<span class="number">300</span>),(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>))</span><br><span class="line"></span><br><span class="line">f = <span class="built_in">open</span>(<span class="string">&#x27;hint.txt&#x27;</span>)</span><br><span class="line"><span class="keyword">for</span> line <span class="keyword">in</span> f.readlines():</span><br><span class="line">    point = line.split()</span><br><span class="line">    flag_image.putpixel([<span class="built_in">int</span>(point[<span class="number">0</span>]),<span class="built_in">int</span>(point[<span class="number">1</span>])],(<span class="number">255</span>,<span class="number">255</span>,<span class="number">255</span>))</span><br><span class="line">f.close()</span><br><span class="line">flag_image.save(<span class="string">&#x27;flag_image.jpg&#x27;</span>)</span><br></pre></td></tr></table></figure>
<p>画了个二维码给我</p>
<p>扫描得到flag</p>
<p>hsnctf{8384b52d-6b32-49d8-a0be-1bb15e9985dc}</p>
<h2 id="密码学"><a href="#密码学" class="headerlink" title="密码学"></a>密码学</h2><h3 id="easyrsa"><a href="#easyrsa" class="headerlink" title="easyrsa"></a>easyrsa</h3><p>=-= 我以后都不想摸密码学了 第一次尝试 差点劝退 废话少说</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> libnum</span><br><span class="line"></span><br><span class="line"><span class="keyword">with</span> <span class="built_in">open</span>(<span class="string">&quot;flag.txt&quot;</span>) <span class="keyword">as</span> f:</span><br><span class="line">    flag = f.read()</span><br><span class="line"></span><br><span class="line">m = libnum.s2n(flag)</span><br><span class="line"></span><br><span class="line">p = getPrime(<span class="number">1024</span>)</span><br><span class="line">q1 = getPrime(<span class="number">1024</span>)</span><br><span class="line">q2 = getPrime(<span class="number">1024</span>)</span><br><span class="line"></span><br><span class="line">e = <span class="number">65537</span></span><br><span class="line">n1 = p * q1</span><br><span class="line">n2 = p * q2</span><br><span class="line">c = <span class="built_in">pow</span>(m, e, n1)</span><br><span class="line"></span><br><span class="line">print(n1, n2, c)</span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">output:</span></span><br><span class="line"><span class="string">19927995886914135335416406082647120895619334038709715664270614604151473749182691765161766917756826761209408429340053534661116540440455731883912107733536490306892185777306017692334819486621137392115368637822832208615896079869167332092773633150006570996052837028257313679389522817781164233607188350606757597836490056930318266077647703629309920052447748365274174530490094908252256551706625163193805930254664728936230312618043386165963458944225026036816776258340041222542638064896328642143272486093326421275373201421890802797828158807121957406664052135737278317985129996476960525575320786302386904366901933941877871977923</span></span><br><span class="line"><span class="string">18891582332322922179757256935338383228362622765536723954262749118724360227437890613511811834258619933112000032816774390665802252670355559592889246899049387975273869584023100438870426265843757686044290924963164327025399130980205072334359825236874676865799829315906270559180981769846264222745663893031262917781276708151305378259082579089031371101323253330053986819164120184785001094503410745573822883437760154804937523455385157947633996347870180978374764506128842545299334183115882288528664242409706229889871455032394406814666870814759869179655535890356720047754561351306758635949531548031922969386197250253432717160713</span></span><br><span class="line"><span class="string">13464724434881083014378360688491414344998156133411847847874051353940035862995104112542330206199732554180770508723141951625606376158124527681508374976085150535523169426812879850201999337951347258663163526945777620586135979743047015305904146804741356004618021619877806139998460893541631182931447449498967591502111403371136690476476964569301404706879044022446236796126968424261474149501366709514040581812492269780027443526915046387838380291031527967274048028552563236517463115042981801314702717397461735551656092225777678039402709019728332707310411968980746101194493745338399939010674127078293589259391068943187148009190</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br></pre></td></tr></table></figure>
<p>关于这种rsa的解法，就是用python自己写个求最大公因数的脚本</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">gcd</span>(<span class="params">a,b</span>):</span></span><br><span class="line">    <span class="keyword">if</span> b ==<span class="number">0</span>:</span><br><span class="line">        <span class="keyword">return</span> a</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        <span class="keyword">return</span> gcd(b,a%b)</span><br></pre></td></tr></table></figure>
<p>输入n1 n2可以得到p</p>
<p>接着呢我们再去求q1</p>
<p>q1=n1/p</p>
<p>下一步求出φ（n）</p>
<p>fv=(q1-1)*(p-1)</p>
<p>继续去求给的e的逆元d</p>
<p>这里我们就要当脚本小子嫖别人脚本了</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">EX_GCD</span>(<span class="params">a,b,arr</span>):</span> <span class="comment">#扩展欧几里得</span></span><br><span class="line">    <span class="keyword">if</span> b == <span class="number">0</span>:</span><br><span class="line">        arr[<span class="number">0</span>] = <span class="number">1</span></span><br><span class="line">        arr[<span class="number">1</span>] = <span class="number">0</span></span><br><span class="line">        <span class="keyword">return</span> a</span><br><span class="line">    g = EX_GCD(b, a % b, arr)</span><br><span class="line">    t = arr[<span class="number">0</span>]</span><br><span class="line">    arr[<span class="number">0</span>] = arr[<span class="number">1</span>]</span><br><span class="line">    arr[<span class="number">1</span>] = t - <span class="built_in">int</span>(a / b) * arr[<span class="number">1</span>]</span><br><span class="line">    <span class="keyword">return</span> g</span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">ModReverse</span>(<span class="params">a,n</span>):</span> <span class="comment">#ax=1(mod n) 求a模n的乘法逆x</span></span><br><span class="line">    arr = [<span class="number">0</span>,<span class="number">1</span>,]</span><br><span class="line">    gcd = EX_GCD(a,n,arr)</span><br><span class="line">    <span class="keyword">if</span> gcd == <span class="number">1</span>:</span><br><span class="line">        <span class="keyword">return</span> (arr[<span class="number">0</span>] % n + n) % n</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        <span class="keyword">return</span> -<span class="number">1</span></span><br></pre></td></tr></table></figure>
<p>d=ModReverse(e,fv)</p>
<p>接着我们去求解flag的公文即可</p>
<p>x=pow(c,d,n1)</p>
<p>这里求出来是数字 我们需要借助libnum模块转化为字符串</p>
<p>完整exp</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding:UTF-8 -*-</span></span><br><span class="line"><span class="keyword">import</span> sys</span><br><span class="line"><span class="comment">#import gmpy2</span></span><br><span class="line">sys.setrecursionlimit(<span class="number">1000000</span>)</span><br><span class="line"><span class="keyword">import</span> libnum</span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">gcd</span>(<span class="params">a,b</span>):</span></span><br><span class="line">    <span class="keyword">if</span> b ==<span class="number">0</span>:</span><br><span class="line">        <span class="keyword">return</span> a</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        <span class="keyword">return</span> gcd(b,a%b)</span><br><span class="line">n1=<span class="number">19927995886914135335416406082647120895619334038709715664270614604151473749182691765161766917756826761209408429340053534661116540440455731883912107733536490306892185777306017692334819486621137392115368637822832208615896079869167332092773633150006570996052837028257313679389522817781164233607188350606757597836490056930318266077647703629309920052447748365274174530490094908252256551706625163193805930254664728936230312618043386165963458944225026036816776258340041222542638064896328642143272486093326421275373201421890802797828158807121957406664052135737278317985129996476960525575320786302386904366901933941877871977923</span></span><br><span class="line">n2=<span class="number">18891582332322922179757256935338383228362622765536723954262749118724360227437890613511811834258619933112000032816774390665802252670355559592889246899049387975273869584023100438870426265843757686044290924963164327025399130980205072334359825236874676865799829315906270559180981769846264222745663893031262917781276708151305378259082579089031371101323253330053986819164120184785001094503410745573822883437760154804937523455385157947633996347870180978374764506128842545299334183115882288528664242409706229889871455032394406814666870814759869179655535890356720047754561351306758635949531548031922969386197250253432717160713</span></span><br><span class="line">c=<span class="number">13464724434881083014378360688491414344998156133411847847874051353940035862995104112542330206199732554180770508723141951625606376158124527681508374976085150535523169426812879850201999337951347258663163526945777620586135979743047015305904146804741356004618021619877806139998460893541631182931447449498967591502111403371136690476476964569301404706879044022446236796126968424261474149501366709514040581812492269780027443526915046387838380291031527967274048028552563236517463115042981801314702717397461735551656092225777678039402709019728332707310411968980746101194493745338399939010674127078293589259391068943187148009190</span></span><br><span class="line">q=gcd(n1,n2)</span><br><span class="line">p=n1/q</span><br><span class="line">fv=(q-<span class="number">1</span>)*(p-<span class="number">1</span>)</span><br><span class="line"><span class="comment">#print(fv)</span></span><br><span class="line"><span class="comment">#fv=19927995886914135335416406082647120895619334038709715664270614604151473749182691765161766917756826761209408429340053534661116540440455731883912107733536490306892185777306017692334819486621137392115368637822832208615896079869167332092773633150006570996052837028257313679389522817781164233607188350606757597836207467980596236451329780790225129217298668351106183416252697727143995584754590162716126998422296947538087031571243444168045363157941999264066082824046684460684499824009561315836532745508925941125102683602011927119583502181606423416442482409087273246881328707856511744869202483322442194834669300162329296093888</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">exgcd</span>(<span class="params">a, b</span>):</span></span><br><span class="line">    <span class="keyword">if</span> b == <span class="number">0</span>:</span><br><span class="line">        <span class="keyword">return</span> <span class="number">1</span>, <span class="number">0</span>, a</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        x, y, q = exgcd(b, a % b)</span><br><span class="line">        x, y = y, (x - (a // b) * y)</span><br><span class="line">        <span class="keyword">return</span> x, y, q</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">inf</span>(<span class="params">a,p</span>):</span></span><br><span class="line">    x, y, q = exgcd(a,p)</span><br><span class="line">    <span class="keyword">if</span> q != <span class="number">1</span>:</span><br><span class="line">        <span class="keyword">raise</span> Exception(<span class="string">&quot;No solution.&quot;</span>)</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        <span class="keyword">return</span> (x + p) % p <span class="comment">#防止负数</span></span><br><span class="line">e=<span class="number">65537</span></span><br><span class="line">d = inf(e,fv)</span><br><span class="line">print(d)</span><br><span class="line"><span class="comment">#d=9485235877388338459999380065338576517355837252292763941456849595829852940049207118459132356264498741003803752763074751059994649777981538678712090706622782224288491129244303460559567253088480702651125460247576604293212419174493885245006343172273753385886937123448718173167474476675246610359684352485270862366337423992351175669664177212418674654079598708277862665159934890222771842941158208886077568225355615629386252999578375534095351608234168867102207724084292461763466248228546556696290682567182443618970247528589347308669724995850142241062404386362946147416210197489601711543859228600031460482974108507617072224129</span></span><br><span class="line"><span class="comment">#c=1346472443488108301437836068849141434499815613341184784787405135394003586299510411254233020619973255418077050872314195162560637615812452768150837497608515053552316942681287985020199933795134725866316352694577762058613597974304701530590414680474135600461802161987780613999846089354163118293144744949896759150211140337113669047647696456930140470687904402244623679612696842426147414950136670951404058181249226978002744352691504638783838029103152796727404802855256323651746311504298180131470271739746173555165609222577767803940270901972833270731041196898074</span></span><br><span class="line">n1=<span class="number">19927995886914135335416406082647120895619334038709715664270614604151473749182691765161766917756826761209408429340053534661116540440455731883912107733536490306892185777306017692334819486621137392115368637822832208615896079869167332092773633150006570996052837028257313679389522817781164233607188350606757597836490056930318266077647703629309920052447748365274174530490094908252256551706625163193805930254664728936230312618043386165963458944225026036816776258340041222542638064896328642143272486093326421275373201421890802797828158807121957406664052135737278317985129996476960525575320786302386904366901933941877871977923</span></span><br><span class="line">x=<span class="built_in">pow</span>(c,d,n1)</span><br><span class="line"><span class="comment">#print(x)</span></span><br><span class="line">flag=libnum.n2s(x)</span><br><span class="line">print(<span class="built_in">str</span>(flag))</span><br></pre></td></tr></table></figure>

    </div>

    
    
    

      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/diazang/2021/04/03/csapp-datalab/" rel="prev" title="csapp_datalab">
      <i class="fa fa-chevron-left"></i> csapp_datalab
    </a></div>
      <div class="post-nav-item">
    <a href="/diazang/2021/04/08/%E6%98%8E%E5%BE%A1%E6%94%BB%E9%98%B2%E5%A4%8D%E7%8E%B0%E8%B5%9Bpwn-fruitpie/" rel="next" title="明御攻防复现赛pwn-fruitpie">
      明御攻防复现赛pwn-fruitpie <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%AC%AC%E5%9B%9B%E5%B1%8A%E6%B5%B7%E5%95%B8%E6%9D%AFwp"><span class="nav-number">1.</span> <span class="nav-text">第四届海啸杯wp</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#pwn-guess"><span class="nav-number">1.1.</span> <span class="nav-text">pwn-guess</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#misc"><span class="nav-number">1.2.</span> <span class="nav-text">misc</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%9A%90%E8%97%8F%E7%9A%84%E4%B9%A6"><span class="nav-number">1.2.1.</span> <span class="nav-text">隐藏的书</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BD%A0%E8%83%BD%E7%9C%8B%E5%88%B0%E5%9B%BE%E7%89%87%E9%87%8C%E7%9A%84flag%E5%90%97"><span class="nav-number">1.2.2.</span> <span class="nav-text">你能看到图片里的flag吗?</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%A5%9E%E7%A7%98%E9%93%83%E5%A3%B0"><span class="nav-number">1.2.3.</span> <span class="nav-text">神秘铃声</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AF%86%E7%A0%81%E5%AD%A6"><span class="nav-number">1.3.</span> <span class="nav-text">密码学</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#easyrsa"><span class="nav-number">1.3.1.</span> <span class="nav-text">easyrsa</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="H.R.P"
      src="https://www.hualigs.cn/image/6015786be4309.jpg">
  <p class="site-author-name" itemprop="name">H.R.P</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/diazang/archives/">
        
          <span class="site-state-item-count">38</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
  </nav>
</div>



      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        <!-- 用下面的符号注释，注释代码用下面括号括起来 -->
<!-- -->

<!-- 







-->


        








      </div>
    </footer>
  </div>

  
  <script src="/diazang/lib/anime.min.js"></script>
  <script src="/diazang/lib/velocity/velocity.min.js"></script>
  <script src="/diazang/lib/velocity/velocity.ui.min.js"></script>

<script src="/diazang/js/utils.js"></script>

<script src="/diazang/js/motion.js"></script>


<script src="/diazang/js/schemes/pisces.js"></script>


<script src="/diazang/js/next-boot.js"></script>




  




  
<script src="/diazang/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'g8R6OK66Q2xJiQieSaxzFqVA-gzGzoHsz',
      appKey     : 'V9mmkUCmucvukcz6LwkONqXa',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : false,
      lang       : '' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
<a href="http://jue-xian.gitee.io/diazang"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#70B7FD; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
<!-- 动态背景 -->
<script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/clicklove.js"></script>


